package com.tms.goods.mapper;

import java.util.List;

import com.tms.goods.domain.TmsGoods;
import org.apache.ibatis.annotations.Select;

/**
 * 订单Mapper接口
 *
 * @author ruoyi
 * @date 2024-10-24
 */
public interface TmsGoodsMapper
{
    /**
     * 查询订单
     *
     * @param id 订单主键
     * @return 订单
     */
    public TmsGoods selectTmsGoodsById(Long id);

    /**
     * 查询订单列表
     *
     * @param tmsGoods 订单
     * @return 订单集合
     */
    public List<TmsGoods> selectTmsGoodsList(TmsGoods tmsGoods);

    /**
     * 新增订单
     *
     * @param tmsGoods 订单
     * @return 结果
     */
    public int insertTmsGoods(TmsGoods tmsGoods);

    /**
     * 修改订单
     *
     * @param tmsGoods 订单
     * @return 结果
     */
    public int updateTmsGoods(TmsGoods tmsGoods);

    /**
     * 删除订单
     *
     * @param id 订单主键
     * @return 结果
     */
    public int deleteTmsGoodsById(Long id);

    /**
     * 批量删除订单
     *
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteTmsGoodsByIds(Long[] ids);


    @Select("select time,count(*) num from tms_goods group by time order by time")
    List<TmsGoods> countGoods();

    @Select("SELECT \n" +
            "    (SELECT COUNT(*) FROM tms_goods WHERE status = '待调度') AS ddd,\n" +
            "    (SELECT COUNT(*) FROM tms_goods WHERE status = '待审核') AS dsh,\n" +
            "    (SELECT COUNT(*) FROM tms_operation WHERE waybill_status = '待发车') AS dfc,\n" +
            "    (SELECT COUNT(*) FROM tms_operation WHERE waybill_status = '运输中') AS ysz,\n" +
            "    (SELECT COUNT(*) FROM tms_goods WHERE status = '待签收') AS dqs,\n" +
            "    (SELECT COUNT(*) FROM exmanagement WHERE processing_status = '待处理') AS dcl,\n" +
            "    (SELECT COUNT(*) FROM tms_silp WHERE return_status = '未回收') AS dhs,\n" +
            "\t\t(select count(*) djd from tms_operation where waybill_status = '待接单') AS djd,\n" +
            "\t\t(select count(*) ycyd from exmanagement) AS ycyd")
    List<TmsGoods> todoGoods();
}
